package com.sicheng.lc.周赛.分类.排列组合计数;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/7/5 21:20
 */
public class 银行中的激光束数量 {
    //https://leetcode.cn/problems/number-of-laser-beams-in-a-bank/
    public int numberOfBeams(String[] bank) {
        int res = 0;
        int last = 0;
        for (String s : bank) {
            int cnt = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '1')
                    cnt++;
            }
            res += last * cnt;
            if (cnt != 0)
                last = cnt;
        }

        return res;

    }
}
